home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19971216-19980424 / 000272_news@newsmaster….columbia.edu _Fri Feb 27 11:15:05 1998.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@newsmaster.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id LAA03147
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Fri, 27 Feb 1998 11:15:04 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id LAA06865
  7.     for kermit.misc@watsun; Fri, 27 Feb 1998 11:15:04 -0500 (EST)
  8. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Newsgroups: comp.protocols.kermit.misc
  11. Subject: Re: Catching errors while executing 'run console-app' commands in K95 ?
  12. Date: 27 Feb 1998 16:15:02 GMT
  13. Organization: Columbia University
  14. Lines: 62
  15. Message-ID: <6d6oq6$7bt$1@apakabar.cc.columbia.edu>
  16. References: <6d6jic$q5a$1@horus.mch.sni.de>
  17. NNTP-Posting-Host: watsun.cc.columbia.edu
  18. Xref: news.columbia.edu comp.protocols.kermit.misc:8464
  19.  
  20. In article <6d6jic$q5a$1@horus.mch.sni.de>,
  21. Michel Dalle <Michel.Dalle@sni.be> wrote:
  22. : I'm still trying to catch all kinds of errors while I'm executing scripts
  23. : with K95. What has me stumped now is the following :
  24. : In a Kermit script, I want to launch a "console application" (something that
  25. : runs in the DOS box of Windows 95 and NT). The console application returns a
  26. : status of 0 if everything is OK, and it sends some messages to STDOUT. If
  27. : the console application failes, it returns a status of 1, 2, 3, ... and
  28. : prints a corresponding message to STDERR (this can be modified if needed).
  29. : How can I :
  30. : 1) know whether Kermit could launch the console application at all (e.g. 
  31. :    no "Bad command or file name" message)
  32. How could you know unless you try?  I suppose you can use an IF EXIST
  33. command to see if the program executable file exists, but of course that
  34. does not guarantee it can be run.
  35.  
  36. : 2) know whether the console application executed correctly or not.
  37. This depends on the program's exit status code.  However, K95 has a bug in
  38. which the return code of a program or command that you start from K95 is not
  39. captured.  This bug is fixed in 1.1.16, to be announced shortly.
  40.  
  41. : 3) if there is an error, catch the error messages from stderr to some
  42. :    variable in the script.
  43. I don't think there is any good way to do this.  First, Windows 95 has
  44. bugs in this area.  When you attempt to start an application from a
  45. different kind of application (16-bit, 32-bit, Console, GUI, etc) and
  46. redirect the application's i/o, handles are clobbered, etc, and matters
  47. deteriorate pretty rapidly from there -- frozen windows, dead system, etc.
  48. Even if it worked, I don't think the Windows shell gives you a way to
  49. redirect stderr.  So assuming the application wrote such messages to
  50. stderr, you'd have to run some other shell that allowed stderr to be
  51. redirected.
  52.  
  53. : 4) if there is no error, catch the stdout messages to some variable in 
  54. :    the script.
  55. There is a mechanism for this, but whether it works depends on the
  56. application and on Windows.  It is the \fcommand() function.  Example that
  57. works:
  58.  
  59.   echo "\fcommand(echo hi there)"
  60.  
  61. prints "hi there".  Here's another that works as long as the file x.x is
  62. not too long:
  63.  
  64.   assign \%n \fcommand(type x.x)
  65.  
  66. This assigns the contents of the x.x file to the variable \%n.
  67.  
  68. : From what I've seen in tests, \v(status) and \v(exitstatus) always return 0,
  69. : and \v(pexitstat) always returns 1, independently of the success or failure
  70. : of the console application (at least on Windows 95... ).
  71. :
  72. Right, that's the bug described above.  We'll have a fix for you soon.
  73.  
  74. - Frank